<?php

namespace app\common\command;

use app\admin\model\CheckInModel;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use app\admin\model\QuanGuanMemberModel;
use think\db\Where;

// 初始化签到数据
class InitCheckDate extends Command
{
    protected function configure()
    {
        $this->setName('initCheckDate')
            ->setDescription('init check date');
    }

    protected function execute(Input $input, Output $output)
    {
        $memberModel = new QuanGuanMemberModel();
        $studentList = $memberModel->where([
            'status' => 1,
            'is_delete' => 1
        ])->whereIn('identity', '1,2')->field('id')->select();
        $currentDate = date("Y-m-d", time());
        foreach ($studentList as $student) {
            $checkInModel = new CheckInModel();
            $checkInModel->create_id = $student['id'];
            $checkInModel->create_time = 0;
            $checkInModel->check_date = $currentDate;
            $checkInModel->save();
        }
        $output->writeln("init success");
    }
}